<?php
include '../includes/cPage.php';
include '../includes/cDates.php';
include '../includes/cDatabase.php';

define("TD_ROW", "<td width='100' align='left'>");
define("CHANGE_DB", "'Change Active Database'");
define("CREATE_DB", "'         Create Database         '");
define("SHOW_DB", "'         Show Databases         '");
define("DELETE_DB", "'        Delete Database        '");
define("UPDATE_CONFIG", "'  Update Game Config  '");
define("ADD_PLAYER_MANUAL", "'     Add Player Manually     '");
define("UPDATE_REMOVE_PLAYER", "'  Update/Remove Player  '");
define("ADD_MEMBER", "'             Add Member             '");
define("UPDATE_REMOVE_MEMBER", "'Update/Remove Member'");
define("ADD_SCORES", "'              Add Scores              '");
define("ADD_SCORES_FROM_FILE", "'    Add Scores From File    '");
define("TRANSFER_PLAYER", "'           Transfer Player          '");
define("ADD_PLAYERS_FROM_FILE", "'    Add Players From File   '");
define("GET_INACTIVE_PLAYERS", "'      Get Inactive Players      '");
define("SHOW_ACTIVE_PLAYERS", "'      Show Active Players      '");
define("CREATE_CUP", "'      Create Cup      '");
define("SELECT_CUP_WEEKS", "'      Select Cup Weeks      '");
define("SHOW_CUP_TABLE", "'      Show Cup Table      '");
define("SHOW_INJURY_TABLE", "'      Show Injury Table      '");
define("UPDATE_INJURY_TABLE", "'      Update Injury Table      '");


$host="localhost";
$user="root";
$password="lizardman";
$database="ffl";

$cPage = new page("Admin");
echo $cPage->getTitle();
echo $cPage->pageStringStart();
echo $cPage->contentStringStart();

if (@$_GET['form'] == "yes")
{
	// Check user and password
	if ($_POST['loginName'] == $user && $_POST['password'] == $password)
	{
		echo"<table>";
		echo"<TR>";
		echo"<TD>FFL Admin</TD></TR>";
		
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".CREATE_DB." ONCLICK=\"window.location.href='http://localhost/Admin/DB_CreateDatabase.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".SHOW_DB." ONCLICK=\"window.location.href='http://localhost/Admin/DB_ShowDatabases.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".DELETE_DB." ONCLICK=\"window.location.href='http://localhost/Admin/DB_DeleteDatabase.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".UPDATE_CONFIG." ONCLICK=\"window.location.href='http://localhost/Admin/DB_UpdateConfigDatabase.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".CHANGE_DB." ONCLICK=\"window.location.href='http://localhost/Admin/DB_ChangeDatabase.php'\">";
		echo"</TD></TR>";
		echo"<TR><TD><BR></TD></TR>";
		
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".ADD_PLAYER_MANUAL." ONCLICK=\"window.location.href='http://localhost/Admin/DB_AddPlayer.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".UPDATE_REMOVE_PLAYER." ONCLICK=\"window.location.href='http://localhost/Admin/DB_UpdateRemovePlayer.php'\">";
		echo"</TD></TR><TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".ADD_MEMBER." ONCLICK=\"window.location.href='http://localhost/Admin/DB_AddMember.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".UPDATE_REMOVE_MEMBER." ONCLICK=\"window.location.href='http://localhost/Admin/DB_UpdateRemoveMember.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".ADD_SCORES." ONCLICK=\"window.location.href='http://localhost/Admin/DB_AddScores.php'\">";
		echo"</TD></TR><TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".ADD_SCORES_FROM_FILE." ONCLICK=\"window.location.href='http://localhost/Admin/DB_AddScores_From_File.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".TRANSFER_PLAYER." ONCLICK=\"window.location.href='http://localhost/Admin/DB_TransferPlayer.php'\">";
		echo"</TD></TR><TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".ADD_PLAYERS_FROM_FILE." ONCLICK=\"window.location.href='http://localhost/Admin/DB_CreateXML.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".GET_INACTIVE_PLAYERS." ONCLICK=\"window.location.href='http://localhost/Admin/DB_GetInactivePlayers.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".SHOW_ACTIVE_PLAYERS." ONCLICK=\"window.location.href='http://localhost/Admin/DB_ShowActivePlayers.php'\">";
		
		echo"</TD></TR></table>";
		
		echo"<BR><BR><table>";
		echo"<TR>";
		echo"<TD>ERICSSON Cup</TD></TR>";
		echo"</table>";
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".CREATE_CUP." ONCLICK=\"window.location.href='http://localhost/Admin/DB_CreateCup.php'\"></TD></TR>";
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".SELECT_CUP_WEEKS." ONCLICK=\"window.location.href='http://localhost/Admin/DB_SelectCupWeeks.php'\"></TD></TR>";
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE=".SHOW_CUP_TABLE." ONCLICK=\"window.location.href='http://localhost/Admin/DB_ShowCupTable.php'\"></TD></TR>";
		
		echo"<BR><BR><table>";
		echo"<TR>";
		echo"<TD>Logs</TD></TR>";
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Captain Log' ONCLICK=\"window.location.href='http://localhost/Admin/DB_ReadDB_captainLog.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Transfer Log' ONCLICK=\"window.location.href='http://localhost/Admin/DB_ReadDB_transferLog.php'\">";
		echo"</TD></TR></table>";
		
		echo"<BR><BR><table>";
		echo"<TR>";
		echo"<TD>Injuries</TD></TR>";
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Show Injury Table' ONCLICK=\"window.location.href='http://localhost/Admin/DB_ShowInjuryTable.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Update Injury Table' ONCLICK=\"window.location.href='http://localhost/Admin/DB_UpdateInjuryTable.php'\">";		
		echo"</TD></TR></table>";
		
		echo"<BR><BR><table>";
		echo"<TD>MySQL</TD></TR>";
		
		echo"<TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='DB Query' ONCLICK=\"window.location.href='http://localhost/Admin/DB_mysql_send.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Show playerlist DB' ONCLICK=\"window.location.href='http://localhost/Admin/DB_ReadDB_playerlist.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Show memberlist DB' ONCLICK=\"window.location.href='http://localhost/Admin/DB_ReadDB_memberlist.php'\">";
		echo"</TD>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='PHP Info' ONCLICK=\"window.location.href='http://localhost/Admin/DB_Info.php'\">";
		echo"</TD></TR><TR>".TD_ROW."<INPUT TYPE='BUTTON' VALUE='Game Test' ONCLICK=\"window.location.href='http://localhost/Admin/DB_GameTest.php'\">";
		echo"</TD></TR></table>";
	}
	else
	{
		echo "ERROR: Login is incorrect.";
	}
}
else
{
?>
<div align="center">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?form=yes" method="POST">
  <table width='400' border='0'>
    <tr>
      <td><div align="center">Login Name</div></td>
      <td><div align="center">Password</div></td>
    </tr>
    <tr>
      <td><div align="center">
        <input type='text' name='loginName' size='20' maxlength='30' value=<?php echo @$_POST['loginName'] ?>>
      </div></td>
      <td><div align="center">
        <input type='password' name='password' size='20' maxlength='30' value=<?php echo @$_POST['password'] ?>>
      </div></td>
    </tr>
	<tr>
	  <td colspan="2" align="center">
	    <p>&nbsp;</p>
	    <p><input name="loginButton" type="submit" id="login" value="LOGIN">
        </p></td>
 	</tr>
  </table>
</form>
</div>

<?php
}
echo $cPage->getContentStringEnd();
echo $cPage->getMenu();
echo $cPage->getClear();
echo $cPage->pageStringEnd();
echo $cPage->getFooter();
?>
